<template>
  <div id="app">
    <div id="nav">
      <router-link to="/home">介绍</router-link>

      <!-- mapbox相关路由 -->
      <router-link v-if="degrade" to="/mapbox">
        mapbox
        <span class="alive">保活</span>
      </router-link>

      <!-- maptalks相关路由 -->
      <router-link v-if="degrade" to="/maptalks">
        maptalks
        <span class="alive">保活</span>
      </router-link>

      <!-- other相关路由 -->
      <router-link to="/other">
        other
        <i class="el-icon-arrow-down" :class="['main-icon', { active: otherSubFlag }]" @click="handleFlag('otherSub')"></i>
      </router-link>
      <div class="sub-menu" v-show="otherSubFlag">
        <router-link to="/other/location">location</router-link>
        <router-link to="/other/communication">communication</router-link>
      </div>

      <router-link to="/all">all</router-link>
    </div>

    <div class="content">
      <router-view/>
    </div>
  </div>
</template>

<script>
export default {
  name: "App",
  data() {
    return {
      otherSubFlag: this.$route.name === "other-sub",
      degrade: window.Proxy,
    };
  },
  methods: {
    handleFlag(name) {
      this[name + "Flag"] = !this[name + "Flag"];
    },
  },
};
</script>

<style>
html,
body {
  margin: 0;
  padding: 0;
  font-size: 16px;
  height: 100vh;
}
#app {
  font-family: Avenir, Helvetica, Arial, sans-serif;
  -webkit-font-smoothing: antialiased;
  -moz-osx-font-smoothing: grayscale;
  color: #2c3e50;
  display: flex;
  flex-direction: row;
  flex-wrap: nowrap;
  width: 100vw;
}
#nav {
  background-color: white;
  flex-shrink: 0;
  font-size: 20px;
  display: flex;
  position: relative;
  z-index: 1;
  flex-direction: column;
  padding: 30px 0;
  width: 210px;
  height: 100vh;
  box-sizing: border-box;
  box-shadow: 3px 0px 9px 2px #e6e6e6;
  transition: transform 0.1s linear;
  transform: translate(0, 0);
  overflow: auto;
}
#nav .menu-icon {
  display: none;
  border: none;
  background: rgb(241, 107, 95) !important;
}
.main-icon {
  padding: 0 10px;
  transition: transform 0.2s ease-in;
}
.main-icon.active {
  transform: rotate(180deg);
}
.sub-menu {
  font-size: 16px;
  padding: 0 10px;
}
.wujie_iframe {
  width: 100%;
  height: 100%;
}
iframe {
  border: none;
}
.content {
  flex: 1;
  height: 100vh;
  overflow: hidden;
  width: 1px;
}
#nav a {
  display: flex;
  align-items: center;
  padding: 10px 30px;
  font-weight: bold;
  color: #2c3e50;
  text-decoration: none;
  transition: all 0.2s linear;
}
#nav a:hover {
  color: rgb(241, 107, 95);
}
.alive {
  display: inline-block;
  white-space: nowrap;
  background-color: rgb(241, 107, 95);
  border-radius: 8px;
  margin-left: 4px;
  font-size: 10px;
  vertical-align: top;
  padding: 1px 4px;
  color: white;
}
#nav a.router-link-active {
  color: rgb(241, 107, 95);
  background: rgba(0, 0, 0, 0.05);
}
</style>
